import Vue from 'vue'
import router from '@/router/index.js'
Vue.directive('permission', {
    inserted(el, binding) {
        //获取权限 
        const action = binding.value.action;
        //是否禁用
        const effect = binding.value.effect
        // 判断当前的路由所对应的组件中是否具备action的权限
        if (!router.currentRoute.meta.permission.includes(action)) {
            if (effect === "disabled") {//禁用
                el.disabled = true;
                el.classList.add('is-disabled')
            } else {//删除
                el.parentNode.removeChild(el)
            }
        }
    }
})